﻿using System;
using System.Runtime.InteropServices;
using System.IO;

namespace SystemModule
{
    /// <summary>
    /// 基本属性结构体
    /// </summary>
    public class TAbility // Size 68
    {
        /// <summary>
        /// 等级
        /// </summary>
        public ushort Level;
        /// <summary>
        /// 防御
        /// </summary>
        public int AC;
        /// <summary>
        /// 魔防
        /// </summary>
        public int MAC;
        /// <summary>
        /// 攻击力
        /// </summary>
        public int DC;
        /// <summary>
        /// 魔法
        /// </summary>
        public int MC;
        /// <summary>
        /// 道术
        /// </summary>
        public int SC;
        /// <summary>
        /// HP
        /// </summary>
        public int HP;
        /// <summary>
        /// MP
        /// </summary>
        public int MP;
        /// <summary>
        /// 最大HP
        /// </summary>
        public int MaxHP;
        /// <summary>
        /// 最大MP
        /// </summary>
        public int MaxMP;
        /// <summary>
        /// 经验值
        /// </summary>
        public int Exp;
        /// <summary>
        /// 最大经验值
        /// </summary>
        public int MaxExp;
        /// <summary>
        /// 背包
        /// </summary>
        public UInt16 Weight;
        /// <summary>
        /// 最大背包
        /// </summary>
        public UInt16 MaxWeight;
        /// <summary>
        /// 负重
        /// </summary>
        public UInt16 WearWeight;
        /// <summary>
        /// 最大负重
        /// </summary>
        public UInt16 MaxWearWeight;
        /// <summary>
        /// 腕力
        /// </summary>
        public UInt16 HandWeight;
        /// <summary>
        /// 最大腕力
        /// </summary>
        public UInt16 MaxHandWeight;
        /// <summary>
        /// 酒量
        /// </summary>
        public UInt16 Alcohol;
        /// <summary>
        /// 酒量上限
        /// </summary>
        public UInt16 MaxAlcohol;
        /// <summary>
        /// 醉酒度
        /// </summary>
        public UInt16 WineDrinkValue;
        /// <summary>
        /// 当前药力值
        /// </summary>
        public UInt16 MedicineValue;
        /// <summary>
        /// 药力值上限
        /// </summary>
        public UInt16 MaxMedicineValue;

        public byte[] ToByte()
        {
            using (var memoryStream = new MemoryStream())
            {
                var backingStream = new BinaryWriter(memoryStream);
                backingStream.Write(Level);
                backingStream.Write(AC);
                backingStream.Write(MAC);
                backingStream.Write(DC);
                backingStream.Write(MC);
                backingStream.Write(SC);
                backingStream.Write(HP);
                backingStream.Write(MP);
                backingStream.Write(MaxHP);
                backingStream.Write(MaxMP);
                backingStream.Write(Exp);
                backingStream.Write(MaxExp);
                backingStream.Write(Weight);
                backingStream.Write(MaxWeight);
                backingStream.Write(WearWeight);
                backingStream.Write(MaxWearWeight);
                backingStream.Write(HandWeight);
                backingStream.Write(MaxHandWeight);

                backingStream.Write(Alcohol);
                backingStream.Write(MaxAlcohol);
                backingStream.Write(WineDrinkValue);
                backingStream.Write(MedicineValue);
                backingStream.Write(MaxMedicineValue);

                var stream = backingStream.BaseStream as MemoryStream;
                return stream.ToArray();
            }
        }

    }
}